package com.woniuxy.mapper;


import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.woniuxy.entity.Bidding;
import com.woniuxy.entity.Collect;
import com.woniuxy.entity.Sign;
 @Mapper
public interface BiddingMapper {
   
	 
	
	 
	 
	
	
	 
	@Insert("insert into collect values(default,#{p_id},#{u_id},#{time},#{time_way},null)")
	public int addCollection(Collect collect);//添加收藏,
	@Select("select count(*) from collect where p_id=#{p_id}")
	public int allCollector(int p_id);//查询此商品的收藏人数
	
	
	@Select("select count(*) from sign where br_id=#{br_id}")
	 public int allsigner(int br_id);//查询该商品所有报名人
	@Select("select count(*) from sign where p_id=#{p_id}")
	public int signer(int p_id);       //查询某拍品报名人数
	@Insert("insert into sign values(#{br_id},#{u_id},#{time},#{p_id})")
	public int addSigner(Sign sign);   //添加报名人数
	
	
	
	
	@Select("select count(c_id) from collect where p_id=#{p_id}")
	public int reminder(int p_id);      //查询某拍品提醒人数
	@Insert("insert into collect values(default,#{p_id},#{u_id},{time},#{time_way}),#{remind_way}")
	public int addReminder(Collect collect); //添加提醒（收藏人数）
	
	
	
	 @Insert("insert into bidding values(default,#{br_id},#{u_id} ,#{alias},#{price},#{time})")
	  public int addBidding(Bidding bidding);//添加竞价记录
	@Select("select  * from bidding where br_id=(select br_id from bidding_room where p_id=#{p_id}) order by price DESC")
	public List<Bidding> findBiddingRecords(int p_id);//查询竞价记录 
	
	 @Select("select max(price) currentPrice from bidding where br_id=(select br_id from bidding_room where p_id=#{p_id})")
	 public BigDecimal currentPrice(int p_id);//查询当前价格


	 @Select("select count(*) from bidding where p_id=#{p_id}")
	 public int findNum(int p_id);

	 
	 
	 
	 
	 
	 
	 @Update("update Product set heat=#{heat}+1 where p_id=#{p_id}")
	 public int addVistor(int p_id);    //增加热度

	
	 
	


}
